<template>
	<view class="info">
		<view class="info-hd">
			<text class="mr10">{{ value.cla_date || '-' }}</text>
			<u-tag v-if="week" shape="circle" plain plainFill type="primary" :text="week" size="mini"></u-tag>
		</view>
		<view class="info-bd ml10" v-if="value.start_time">
			<view>{{value.start_time}} ~ {{ value.end_time }}</view>
			<view class="ml10">
				<u-tag v-if="diff" shape="circle" type="primary" :text="diff" size="mini"></u-tag>
			</view>
		</view>
	</view>
</template>

<script>
	/**
	 * 获取上课时间信息
	 */
	import {
		getWeek
	} from '@/codecat/config/index'
	export default {
		// 课程信息
		props: {
			value: {
				type: Object,
				default: () => {}
			}
		},
		computed: {
			week() {
				return this.value?.cla_date ? '周' + getWeek(this.value.cla_date) : ''
			},
			diff() {
				const {
					cla_date,
					start_time,
					end_time
				} = this.value
				if (!cla_date) return ''
				const diff = this.$dayjs(`${cla_date} ${end_time}`).diff(`${cla_date} ${start_time}`, 'minute')
				return diff + '分钟'
			}
		},
	}
</script>

<style lang="scss" scoped>
	.info {
		display: flex;
		align-items: center;

		&-hd {
			@include center;
		}

		&-bd {
			@include center;
		}
	}
</style>